package com.wbcs.config;

import java.util.HashMap;
import java.util.Map;

import com.wbcs.util.Consts_Private;

public class OnloadMethodBean implements Comparable<OnloadMethodBean>,Cloneable
{
    private String type;

    private String method;

    public OnloadMethodBean(String type,String method)
    {
        this.type=type;
        this.method=method;
    }
    
    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type=type;
    }

    public String getMethod()
    {
        return method;
    }

    public void setMethod(String method)
    {
        this.method=method;
    }

    private final static Map<String,Integer> mOnloadTypeInvokeOrder=new HashMap<String,Integer>();

    static
    {

        mOnloadTypeInvokeOrder.put(Consts_Private.ONlOAD_CURVETITLE,2);
        mOnloadTypeInvokeOrder.put(Consts_Private.ONlOAD_IMGSCROLL,2);

        mOnloadTypeInvokeOrder.put(Consts_Private.ONLOAD_CONFIG,4);
        mOnloadTypeInvokeOrder.put(Consts_Private.ONLOAD_REFRESHSLAVE,5);
    }

    public int compareTo(OnloadMethodBean comparedObj)
    {
        if(!mOnloadTypeInvokeOrder.containsKey(this.type)||!mOnloadTypeInvokeOrder.containsKey(comparedObj.getType()))
        {
            return 1;
        }
        if(mOnloadTypeInvokeOrder.get(this.type)>mOnloadTypeInvokeOrder.get(comparedObj.getType()))
        {
            return 1;
        }else if(mOnloadTypeInvokeOrder.get(this.type)<mOnloadTypeInvokeOrder.get(comparedObj.getType()))
        {
            return -1;
        }
        return 0;
    }

    @Override
	public Object clone()
    {
        try
        {
            return super.clone();
        }catch(CloneNotSupportedException e)
        {
            e.printStackTrace();
            return this;
        }
    }
}
